package com.example.innospace.demos.web.mapper;

import com.example.innospace.demos.pojo.dto.AdminDTO;
import com.example.innospace.demos.pojo.dto.AdminPageQueryDTO;
import com.example.innospace.demos.pojo.entity.Admin;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {

    @Select(value = "select * from admin where admin_id=#{adminId}")
    Admin findById(@Param("adminId")String adminId);


    void updateAminInfo(Admin adminId);

    @Insert("insert into admin (admin_id,username,password,name,level,college,gender,phone,email,status,avatar) values " +
            "(#{adminId},#{username},#{password},#{name},#{level},#{college},#{gender},#{phone},#{email},#{status},#{avatar});")
    void insert(AdminDTO adminDTO);


    void batchDeleteById(@Param("adminIds") List<String> adminIds);

    @Update("update  admin set status=#{status} where admin_id=#{adminId}")
    void adminstartOrstop(@Param("status") Integer status,  @Param("adminId")String adminId);



    Page<Admin> pageQuery(AdminPageQueryDTO adminPageQueryDTO);

    @Update("update admin set avatar=#{fileUrl}  where admin_id=#{adminId}")
    void updateAvatar(@Param("adminId") String adminId, @Param("fileUrl") String fileUrl);

    @Select("select avatar from admin where admin_id=#{adminId}")
    String getAvatar(@Param("adminId") String adminId);
}
